package com.qtcm.nas.fyx.chakanxiangqing.web;

import com.alibaba.druid.support.json.JSONParser;
import com.alibaba.druid.support.json.JSONUtils;
import com.qtcm.nas.fyx.chakanxiangqing.pojo.Chuzhi_card;
import com.qtcm.nas.fyx.chakanxiangqing.pojo.Package_Details;
import com.qtcm.nas.fyx.chakanxiangqing.pojo.YearCard;
import com.qtcm.nas.fyx.chakanxiangqing.service.ICkxqService;
import com.qtcm.nas.fyx.huiyuantianjia.pojo.Car_fyx;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller("ckxqController")
@RequestMapping("/ckxq")
public class CkxqController {
    @Autowired
    @Qualifier("ckxqService")
    private ICkxqService ckxqService;

    @RequestMapping("/findCar")
    public String findCar(int id, Model model){
        List<Car_fyx> car = ckxqService.findCar(id);
        model.addAttribute("car",car);
        Package_Details lb = ckxqService.finddlb(id);
        model.addAttribute("lb",lb);
        Chuzhi_card findchuzhi = ckxqService.findchuzhi(id);
        int findcardid = ckxqService.findcardid(id);
        findchuzhi.setCard_id(findcardid);
        String finddianpu = ckxqService.finddianpu(id);
        findchuzhi.setDianpu(finddianpu);
        System.out.println(findchuzhi);
        model.addAttribute("findchuzhi",findchuzhi);
        YearCard findnian = ckxqService.findnian(id);
        model.addAttribute("findnian",findnian);
        model.addAttribute("hyid",id);
        return "user_Detail";
    }

    @RequestMapping("/findLb")
    public ModelAndView findLb(int hyid, Package_Details dlb){
        ModelAndView model=new ModelAndView();
        dlb = ckxqService.findLb(hyid);
        String findnp = ckxqService.findnp(hyid);
        dlb.setC_name(findnp);
        String findphone = ckxqService.findphone(hyid);
        dlb.setC_phone(findphone);
        model.addObject("dlb",dlb);
        System.out.println(dlb.toString());
        model.setViewName("user_Package");
        return model;
    }
}
